
import axios from 'axios'

export function loadDictList(dictCode: string, callback: any) {
    var inParm = {
        'isDownExcel': '0',
        DICT_CODE: dictCode
    };

    axios.post("/api/sys/dict/list", inParm).then(res => {
        if (res.data.code == "200") {
            //请添加执行成功后的业务代码 
            if (res.data != null && res.data.success) {
                callback(res.data.data.list);
            }
        } else {
            // 错误消息为：res.data.msg 
            // 请添加执行失败后的业务代码 
            console.log(res.data)
        }
    });
}
export function loadDictMap(dictCode: string, callback: any) {
    var inParm = {
        'isDownExcel': '0',
        DICT_CODE: dictCode
    };

    axios.post("/api/sys/dict/list", inParm).then(res => {
        if (res.data.code == "200") {
            //请添加执行成功后的业务代码 
            if (res.data != null && res.data.success) {
                // 循环构建Map

                let refMap = {};
                for(var i = 0 ; i < res.data.data.list.length ; i++){
                    refMap[res.data.data.list[i].VALUE] = res.data.data.list[i];
                }
                callback(refMap);
            }
        } else {
            // 错误消息为：res.data.msg 
            // 请添加执行失败后的业务代码 
            console.log(res.data)
        }
    });
}
